"""
用数组实现队列
"""


class Queue(object):
    def __init__(self):
        self.elements = []

    def is_empty(self):
        return self.elements == []

    def enqueue(self, item):
        """入队"""
        # 尾插
        self.elements.append(item)
        # 头插
        # self.elements.insert(0, item)

    def dequeue(self):
        """出队"""
        # 头出
        return self.elements.pop(0)
        # 尾出
        # return self.elements.pop()

    def get_head(self):
        """获取队头元素"""
        return self.elements[0]

    def get_rear(self):
        """获取队尾元素"""
        return self.elements[-1]

    def size(self):
        """队列大小"""
        return len(self.elements)


